<?php
//引入数据库类
require_once dirname(__FILE__).'/../dao/MysqlDb.class.php';

/*
 * 超级管理员(对于管理员进行增删查改)
 */
class SuperManagerModel{
	
	//显示所有管理员(权限为50)
	public function allManagersShow(){
		//获得数据库实例
		$mySqlDb = MySqlDb::getMySqlDb();
		$sql = "select `manager_account`,`manager_sex`,`right_control` from managers where `right_control`='50';";
		$allManagersShowInfo = $mySqlDb->fetchAll($sql);
		//返回信息
		return $allManagersShowInfo;
	}
	
	//删除管理员(根据管理员账号)
	public function deleteManager($courseOrStudentId){
		//获得数据库实例
		$mySqlDb = MySqlDb::getMySqlDb();
		$mySqlDb->escapeString($courseOrStudentId);
		$sql = "delete from managers where `manager_account`='$courseOrStudentId';";
		//执行删除
		$mySqlDb->query($sql);
	}
	
	//显示待审核管理员信息(权限为0)
	public function showAllCanAllowManagers(){
		$mySqlDb = MySqlDb::getMySqlDb();
		$sql = "select `manager_account`,`manager_sex`,`right_control` from managers where `right_control`='0';";
		$showAllCanAllowManagersInfo = $mySqlDb->fetchAll($sql);
		return $showAllCanAllowManagersInfo;
	}
	
	//通过审核
	public function AllowManager($courseOrStudentId){
		$mySqlDb = MySqlDb::getMySqlDb();
		$mySqlDb->escapeString($courseOrStudentId);
		$sql = "update managers set `right_control`='50' where `manager_account`='$courseOrStudentId';";
		//执行审核
		$mySqlDb->query($sql);
	}
	
	
}

//单元测试
/* $test = new SuperManagerModel(); */
//所有管理员信息
/* $showAllCanAllowManagersInfo = $test->allManagersShow();
foreach ($showAllCanAllowManagersInfo as $row){
	echo '账号：'.$row['manager_account'].'&nbsp&nbsp';
	echo '性别：'.$row['manager_sex'].'&nbsp&nbsp';
	echo '权限：'.$row['right_control'].'<br/>';
} */
//所有待审核管理员信息
/* $canAllowManagerInfo = $test->showAllCanAllowManagers();
foreach ($canAllowManagerInfo as $row){
	echo '账号：'.$row['manager_account'].'&nbsp&nbsp';
	echo '性别：'.$row['manager_sex'].'&nbsp&nbsp';
	echo '权限：'.$row['right_control'].'<br/>';
} */

?>